package cn.com.bluemoon.daps.system.dto;

import cn.com.bluemoon.daps.common.constant.DapConstant;
import cn.com.bluemoon.daps.system.entity.DapSystemLogin;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

/**
 * 用户信息
 *
 * @author Jarod.Kong
 * @date 2021/3/29 13:21
 */
@Data
public class SystemUserDto implements Serializable {

    @ApiModelProperty(value = "用户名称")
    private String userName;

    @ApiModelProperty(value = "用户id，内部账号")
    private String account;

    @ApiModelProperty(value = "用户手机号码")
    private String mobile;

    @ApiModelProperty(value = "是否为DBA角色用户")
    private Boolean dbaRole;

    @ApiModelProperty("邮箱")
    private String email;

    public SystemUserDto() {
    }

    public SystemUserDto(DapSystemLogin dapSystemLogin) {
        this.account = dapSystemLogin.getAccount();
        this.mobile = dapSystemLogin.getMobile();
        this.userName = dapSystemLogin.getUserName();
        this.dbaRole = dapSystemLogin.getDbaRole();
        this.email = dapSystemLogin.getEmail();
    }

    public String getEmail() {
        return email;
    }

    /**
     * 是否个格式化账号 位数
     *
     * @return 结果
     */
    public String getEmailByAccount() {
        return DapConstant.formatEmail(this.getAccount(), true);
    }
}
